package com.wens.monitor.dao;

import java.util.Date;
import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;

import com.wens.monitor.model.Performancedata;

public class PerformancedataDAO extends DAO{
//	private static SessionFactory factory = HibernateUtil.getSessionFactory();
	
	public static List<Performancedata> getRecords(Date startDate,
			Date endDate, String IP) {
		Session session = factory.getCurrentSession();
		session.beginTransaction();
		Query q = session.createQuery("from Performancedata p where p.server.IP = :IP " +
				"and p.createDate between :startDate and :endDate")
				.setDate("startDate", startDate)
				.setDate("endDate", endDate)
				.setString("IP", IP);
//		Query q = session.createQuery("from Performancedata p where p.server.IP = :IP")
//				.setString("IP", "1.1.1.1");
		List<Performancedata> list = q.list();
		
		session.getTransaction().commit();
		return list;
	}
	
	//TODO delete

	
}
